import gevent, time
from gevent import monkey

def task(index, dd):
    for i in range(3):
        print(" 任务%d --- 代码块%d,当前的gevent对象名称:%s"%(index, i, str(gevent.getcurrent())))
        time.sleep(1)
    return 1000+dd
if __name__ == '__main__':
    # 打补丁
    monkey.patch_all()

    t1 = gevent.spawn(task,1, 7)
    t2 = gevent.spawn(task,2, 8)
    t3 = gevent.spawn(task,3, 9)
    gevent.joinall([t1,t2,t3])
    print(t1.value)
    print(t2.value)
    print(t3.value)

    print("主线程执行的最后代码...")

